package org.nf.servlet;

import org.nf.demo.entity.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author czl
 * @Date 2024-04-24
 */
@WebServlet("/show")
public class ShowStudentServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Student stu = new Student("张三","男",18) ;

        String str = stu.showInfo();

        req.setAttribute("stu",str);

        // 转发页面
        req.getRequestDispatcher("showinfo.jsp").forward(req,resp);
    }
}
